#!/usr/bin/env python3
#使用埃拉托色尼筛选法生成素数序列
import functools
import time

def metric(fn):
    @functools.wraps(fn)
    def wrapper(*args, **kw):
        t1 = time.time()
        func = fn(*args, **kw)
        t2 = time.time()
        print('%s executed in %s s' % (fn.__name__, t2 - t1))
        return func
    return wrapper
    
def _odd_iter():
    n = 1
    while True:
        n += 2
        yield n

def _not_divisible(n):
    return lambda x: x % n > 0

def primes():
    yield 2
    it = _odd_iter()
    while True:
        n = next(it)
        yield n
        it = filter(_not_divisible(n), it)

@metric
def main():
    for n in primes():
        if n < 100000:
            print(n, end = ' ')
        else:
            break

main()